<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const p1 = new Promise((resolve,reject)=>{
            try{
                // throw new Error('我是错误')
                setTimeout(()=>{
                    resolve('wocheng')
                },1200)
            }catch(e){
                reject(e.message)
            }
        })

        console.log(p1);
        const p2 = p1.then((value)=>{
            //value 上一个promise成果的值
                return  new Promise((resolve,reject)=>{
                    try{
                        //施行正常的AJAX获取参数
                        resolve('wsohizhu1')
                    }catch(e){
                        //没有获取成功
                        reject()
                    }
                })
            })
        console.log(p2);

        const p3 = p1.finally(()=>{
            return new Promise((resolve ,reject)=>{
                try{
                    // throw new Error('错误')
                    setTimeout(()=>{
                        resolve('我成功了')
                    },1000)
                }catch(e){
                    reject(e.message)
                }
            })
        })
        console.log(p3);
        

        // const p3 = p1.catch((reason)=>{
        //     throw reason
        // })



    </script>
</body>
</html>